﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CS3230HealthTrackerSystemGUI
{
    public partial class AddUser : Form
    {

        /*Creates the variables to hold the information for the current patient
         * to be registered.
         */
        private String currentEmployeeFirstName;
        private String currentEmployeeLastName;
        private String currentEmployeeBirthDate;
        private String currentEmployeeAddressStreetNumber;
        private String currentEmployeeStreet;
        private String currentEmployeeAddressCity;
        private String currentEmployeeAddressState;
        private String currentEmployeeAddressZip;
        private String currentEmployeeContact;
        private String currentEmployeeUserType;
        private String currentEmployeePassword;
        private String currentEmployeeRepassword;
        private String currentEmployeeIs;
        private Validation validate = new Validation();
        private Decryption key = new Decryption();

        public AddUser()
        {
            InitializeComponent();
        }

        private void addUserButton_Click(object sender, EventArgs e)
        {
            try
            {
                //Gets all the information for the employee from the text.
                currentEmployeeFirstName = employeeFirstNameText.Text.Trim();
                currentEmployeeLastName = employeeLastNameText.Text.Trim();
                currentEmployeeBirthDate = employeeBirthdateText.Text;
                currentEmployeeAddressStreetNumber = employeeAddressStreetNumberText.Text;
                currentEmployeeStreet = employeeAddressStreetText.Text;
                currentEmployeeAddressCity = employeeAddressCityText.Text;
                currentEmployeeAddressState = employeeAddressStreetText.Text;
                currentEmployeeAddressZip = employeeAddressZipText.Text;
                currentEmployeeContact = employeeContactNumberText.Text;
                currentEmployeePassword = employeePasswordTextBox.Text;
                currentEmployeeRepassword = reEnterEmployeePasswordTextBox.Text;
                currentEmployeeIs = " ";
                
                /*
                 *Logic to check which radio button is set.
                 *Afterwards sets the private currentEmployee to a string value of what the new employee is.
                 */
                if(nurseRadioButton.Checked == true && adminRadioButton.Checked == false && doctorRadioButton.Checked == false)
                {
                    currentEmployeeIs = "nurse";

                }
                else if (nurseRadioButton.Checked == false && adminRadioButton.Checked == true && doctorRadioButton.Checked == false)
                {
                    currentEmployeeIs = "admin";
                }
                else if (nurseRadioButton.Checked == false && adminRadioButton.Checked == false && doctorRadioButton.Checked == true)
                {
                    currentEmployeeIs = "doctor";
                }
                else
                {
                    MessageBox.Show("You did not select a proper employee type.");
                }

                /*
                 * Logic to check to see if the passwords match.
                 * If they don't match shows a message box that will tell the user which password does not match the other.
                 */
                if (currentEmployeePassword != currentEmployeeRepassword)
                {
                    MessageBox.Show("The employee password does not match the re-enter password");
                }
                else if (currentEmployeeRepassword != currentEmployeePassword)
                {
                    MessageBox.Show("The re-enter password  does not match the employee password does not match");
                }
                else 
                {
                    
                }

                //Gathers data from each of the text boxes and verify the data is valid. 
                validate.validateName(currentEmployeeFirstName, "First");
                validate.validateName(currentEmployeeLastName, "Last");
                validate.validatePhoneNumber(currentEmployeeContact);
                validate.validateDate(currentEmployeeBirthDate);
                validate.validateAddressStreetNumber(currentEmployeeAddressStreetNumber);
            }
            //Throws an exception if something is incorrectly formatted.
            catch (Exception formatException)
            {
                MessageBox.Show(formatException.Message);
            }
        }
    }
}
